home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / UUCP / UUCon / Source / Defaults.m < prev    next >
Text File  |  1992-08-17  |  2KB  |  123 lines

  1. /*
  2.  
  3.   Ronin Consulting, Inc.
  4.     Copyright (C) 1992, Nicholas Christopher (nwc@gun.com)
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public
  17.     License along with this library; if not, write to the Free
  18.     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. */
  21. /*
  22. ** Defaults.m,v 1.1.1.1 1992/08/18 14:34:21 nwc Exp
  23. **
  24. */
  25.  
  26. #import "Defaults.h"
  27. #import <appkit/Application.h>
  28.  
  29. @implementation Defaults
  30.  
  31. static id  theOnlyOne = nil;
  32. static NXDefaultsVector noDefs = {{NULL}};
  33.  
  34. + new
  35. {
  36.    if(!theOnlyOne)
  37.    {
  38.       theOnlyOne = self = [super new];
  39.       appName = [NXApp appName];
  40.       registered = NO;
  41.    }
  42.    else
  43.        self = theOnlyOne;
  44.    
  45.    return self;
  46. }
  47.  
  48.  
  49. - regDefaults:(NXDefaultsVector) defaultsVector
  50. {
  51.    NXRegisterDefaults(appName, defaultsVector);
  52.    registered = YES;
  53.    return self;
  54. }
  55.  
  56.  
  57. - (const char *)get: (const char *) aDefault
  58. {
  59.    if(!registered)
  60.        [self regDefaults: noDefs];
  61.  
  62.    return NXGetDefaultValue(appName, aDefault);
  63. }
  64.  
  65. - set: (const char *) aDefault to: (const char *)aValue
  66. {
  67.    if(!registered)
  68.        [self regDefaults: noDefs];
  69.  
  70.    NXSetDefault(appName, aDefault, aValue);
  71.    return self;
  72. }
  73.  
  74. - (const char *) readDB: (const char *) aDefault
  75. {
  76.    if(!registered)
  77.        [self regDefaults: noDefs];
  78.  
  79.    return NXReadDefault(appName, aDefault);
  80. }
  81.  
  82. - writeDB: (const char *) aDefault as: (const char *)aValue
  83. {
  84.    if(!registered)
  85.        [self regDefaults: noDefs];
  86.  
  87.    NXWriteDefault(appName, aDefault, aValue);
  88.    return self;
  89. }
  90.  
  91.  
  92. - remove: (const char *) aDefault
  93. {
  94.    if(!registered)
  95.        [self regDefaults: noDefs];
  96.  
  97.    NXRemoveDefault(appName, aDefault);
  98.    return self;
  99. }
  100.  
  101. - update: (const char *) aDefault
  102. {
  103.    if(!registered)
  104.        [self regDefaults: noDefs];
  105.  
  106.    NXUpdateDefault(appName, aDefault);
  107.    return self;
  108. }
  109.  
  110. - update
  111. {
  112.    if(!registered)
  113.        [self regDefaults: noDefs];
  114.  
  115.    NXUpdateDefaults();
  116.    return self;
  117. }
  118.  
  119.  
  120. @end
  121.  
  122.  
  123.